home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / util / rexx / FWCalendar.lha / gui4cli.lha / Gui4Cli / Tools / Rtn / ViewFile < prev   
Encoding:
Text File  |  1998-07-06  |  3.0 KB  |  146 lines

  1. G4C  
  2.  
  3. ; ViewFile FileName FileType Mode
  4.  
  5. ; FileName = the File Name
  6. ; FileType = the File Type, as returned from the GetFileType routine
  7. ; Mode     = (optional) CLI or RUN (RUN is default)
  8.  
  9. ; ======================================================================
  10.  
  11. xONLOAD filename filetype mode
  12. guiopen viewfile $filename $filetype $mode
  13.  
  14. xONRELOAD filename filetype mode
  15. guiopen viewfile $filename $filetype $mode
  16.  
  17. xONOPEN filename filetype mode
  18.  
  19. if $filename = ''
  20. or $filetype = ''
  21.    return
  22. endif
  23.  
  24. docase $filetype
  25.  
  26. ; ----- do special cases first.
  27.  
  28. case   = TEXT                        ; a text file (probably)
  29.        GuiLoad guis:tools/read.gc $viewfile/filename
  30.        return
  31.        break
  32.  
  33. case   = INFO                     ; icons
  34.        if $filename[-1][1] = \"    ; remove the .info extention
  35.           cutvar filename cut char -6 ''
  36.           appvar filename \"
  37.        else
  38.           cutvar filename cut char -5 ''
  39.        endif
  40.        guiload guis:tools/icon.gc $viewfile/filename
  41.        return
  42.        break
  43.  
  44. case   = G4C                  ; Yes.. you guessed it.
  45.        GuiLoad $filename
  46.        return
  47.        break
  48.  
  49. case   = LHA                  ; LhA - all these are CLI'ied
  50.        cli '$*DEF.LHA x $filename ram:'
  51.        return
  52.        break
  53.   
  54. case   = LZX                  ; LZX
  55.        cli 'LZX x $filename ram:'
  56.        return
  57.        break
  58.  
  59. case   = ZIP                  ; unzip - it blocks the shell - why ???
  60.        cli 'run >nil: <nil: $*DEF.UNZIP $filename -d ram:'
  61.        return
  62.        break
  63.  
  64. case   = EXE                  ; A program ? - Use cli.gc to run it.
  65.        GuiLoad guis:tools/cli.gc $viewfile/filename RUN
  66.        return
  67.        break
  68.  
  69. case   = UNKNOWN
  70.        ; gui to deal with it..
  71.        guiopen ViewFile2
  72.        return
  73.        break
  74.  
  75. endcase
  76.  
  77. ; If we got this far, then it's one of the simple types such as
  78. ; GIF or ILBM etc - We just contruct & issue the command to run it.
  79.  
  80. com = '\$*DEF.$filetype'       ; construct command name
  81. if $mode == CLI
  82.    CLI '$com $filename'  
  83. else
  84.    RUN '$com $filename'  
  85. endif
  86.  
  87.  
  88. ; routine ends here.
  89.  
  90. xOnQuit
  91. guiquit ViewFile2
  92.  
  93.  
  94. ; ######################################################################
  95.  
  96.      NEWFILE Viewfile2     ; last chance gui
  97.  
  98. ; ######################################################################
  99.  
  100. WinBig 0 0 80 90 ""
  101. WinType 00001000
  102. winonmouse 40 10
  103. varpath viewfile    ; merge variables with the above file
  104.  
  105. xOnRMB 
  106. guiclose ViewFile2
  107.  
  108. xOnInactive
  109. guiclose ViewFile2
  110.  
  111. xOnFail
  112. ezreq "Error during operation" OK ""
  113.  
  114. ;---------------> the Buttons
  115.  
  116. xbutton 0 0 0 15 MView
  117. guiclose ViewFile2
  118. run 'multiview $filename screen'
  119.  
  120. xbutton 0 15 0 15 List
  121. GuiLoad  guis:tools/read.gc $viewfile/filename
  122.  
  123. xbutton 0 30 0 15 Play16
  124. guiclose ViewFile2
  125. run '$*DEF.SMPL $filename'
  126.  
  127. xbutton 0 45 0 15 Run
  128. guiclose ViewFile2
  129. run '$filename'
  130.  
  131. xbutton 0 60 0 15 With..
  132. guiclose ViewFile2
  133. prog = ''
  134. ReqFile  -1 -1 300 220 'Run file with..' LOAD prog hd1:Players
  135. if $prog > ''
  136.    run '$prog $filename'
  137. endif
  138.  
  139. xbutton 0 75 0 15 'CliGui'
  140. guiclose ViewFile2
  141. setvar cl_Main '$filename '
  142. GuiLoad guis:tools/cli.gc $viewfile/filename CLI
  143. setgad cli.gc 1 ON
  144.  
  145.  
  146.